﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Script.Serialization;

namespace DC.BLL
{
    public partial class CardService : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            IList<CouponItemCard> cards = XmlProvider.GetAllItemCard().Where(o=>o.ExpiredDate>=DateTime.Today).ToList();
            foreach (CouponItemCard card in cards)
            {
                card.CardUrl = card.CardUrl.Replace(AppSetting.ImgBaseUrl, "~/");
                card.ThumbUrl = card.ThumbUrl.Replace(AppSetting.ImgBaseUrl, "~/");
            }
            JavaScriptSerializer jsSer = new JavaScriptSerializer();
            string json = jsSer.Serialize(cards);
            var context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            context.Response.Write(json);
            context.Response.Flush();
            context.Response.End();
        }
    }
}
